<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="mui/mui.min.css">
    <link rel="stylesheet" href="mui/mui.picker.min.css">
    <link rel="stylesheet" href="mui/mui.showLoading.css">
    <link rel="stylesheet" href="css/video-js.min.css">
    <link rel="stylesheet" href="css/login.css?20180821">
    <script src="js/flexible.js"></script>
    <title>登录</title>
</head>

<body>
    <div id="app" class="app">

        <div class="left_logo">
            <img src="img/left_logo.png" alt="">
        </div>
        <div class="right_logo">
            <img src="img/right_logo_h.png" alt="">
        </div>
        <div class="title">
            <img src="img/title.png" alt="">
        </div>
        <div class="bottom_logo" align="center">
            <img src="img/paodao.png" alt="">
        </div>
        <div class="content">
            <div class="phone">
                <input type="text" placeholder="请输入您的手机号" v-model.trim="phone">
            </div>
            <div class="btn" @click="login">马上起飞</div>
            <div class="footer">
                <div class="checkbox1">
                    <input type="checkbox" id="checkbox2" v-model="checked" value="否" name="test" class="check">
                    <label for="checkbox1" style="min-width: 16px;"></label>
                </div>
                <span class="p16" style="margin-left: 16px;">我愿意接受长荣航空最新活动信息</span>
            </div>
        </div>

    </div>
    <script src="mui/mui.min.js"></script>

    <script src="mui/mui.showLoading.js"></script>
    <script src="js/plugins/video.min.js"></script>
    <script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="js/config.js"></script>
</body>
<script>
    var url = appconfig.apiUrl;
    let vm = new Vue({
        el: "#app",
        data: {
            phone: '',
            theRequest: '',
            checked: true

        },
        methods: {
            geUrl: function () {
                var theRequest = {};
                var url = decodeURIComponent(location.search); //获取url中"?"符后的字串
                if (url.indexOf("?") != -1) {
                    var str = url.substr(1);
                    var strs = str.split("&");
                    for (var i = 0; i < strs.length; i++) {
                        theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                    }
                }
                return theRequest;
            },
            verifyPhone: function () {
                var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;//手机号正则验证
                if (this.phone == "" || reg.test(this.phone) == false) {
                    this.results = false;
                } else if (this.phone == !"" || reg.test(this.phone) == true) {
                    this.results = true;
                }
            },
            login(val) {
                var self = this;
                self.verifyPhone();
                if (self.results == false) {
                    mui.toast('手机号不正确', { duration: 'long', type: 'div' })
                    return;
                } else if (self.disabled == false) {
                    return;
                }
                mui.showLoading('登录中');
                var param = {
                    id: this.theRequest.id,
                    phone: self.phone
                };
                if (self.checked == true) {
                    param["is_send_message"] = 'Y';
                } else if (self.checked == false) {
                    param["is_send_message"] = 'N';
                }
                axios({
                    method: "POST",
                    url: url + '/luckdraw/luckDrawLogin',
                    data: param
                }).then(function (res) {
                    mui.hideLoading();
                    if (res.data.code == "-1") {
                        self.isBtn = true;
                        mui.alert(res.data.msg, " ");
                    }
                    if (res.data.code == "0") {
                        var vip_id = res.data.data.id;
                        console.log(vip_id);
                        window.location.href = "game.html?id=" + self.theRequest.id + "&vip_id=" + vip_id + "&t=" + new Date().getTime();
                    }
                }).catch(function (err) {
                    mui.hideLoading();
                    console.log(err);
                    mui.alert("服务器异常", " ")
                });
            },

        },
        mounted() {
            this.theRequest = this.geUrl();
        }
    })
</script>

</html>